package com.song.sample.service.impl;


import com.song.sample.config.pagination.Page;
import com.song.sample.dao.UserMapper;
import com.song.sample.entity.User;
import com.song.sample.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;


/**
 * @desc:
 * @author: WUSONG
 * @date: 2018/6/25 0025 下午 2:51
 */
@Service
public class UserServiceImpl implements UserService {

/*    @Autowired
    private RestTemplate restTemplate;*/

    @Override
    public User getUserById(Long userId) {
        return userMapper.getUserById(userId); //内部调用
        //作为客户端调用其他服务器数据
//        User user = restTemplate.getForEntity("http://localhost:8080/api/users/{userId}", User.class, userId).getBody();
//        return user;
    }

    @Override
    public Page<User> queryUsers(User user, Pageable pageable) {
        return userMapper.queryAllUsers(user, pageable);
    }

    @Autowired
    private UserMapper userMapper;
}
